Conversation
…round a spec while preserving PM hand-edits Resolves the long-standing "AI-assisted spec merge mode" open question. Re-running `new` / `tech` / `tasks` would clobber PM edits — `refine` is the alternative. Reads the chosen file, treats it as ground truth for what the PM wants, prints it plus its source-of-truth (scanner / overview, plus the upstream spec for tech/tasks), then prints a three-phase agent instruction: audit each section as strong/weak, re-ground only the weak ones, write the file back preserving strong sections character-for-character and any YAML frontmatter at the top of `product-spec.md`. Different shape from `clarify`: clarify finds gaps and walks the PM through them; refine takes the existing spec as ground truth and re-grounds the parts that need it. Hard rules in the prompt: no fabricated code references (mark `(unverified)` or remove if the source-of-truth doesn't surface it), no scope creep (refine ≠ add new features / edge cases — gaps go under Open questions), and don't touch sections that are already strong. Bar for "weak" is "actively misleads or under-specifies," not "could be tighter," so the agent doesn't churn good prose. Same auto-pick / multi-spec / unknown-slug ergonomics as `tech`. Filters specs by which file the requested type requires; `tech`/`tasks` additionally validate that the upstream spec exists. Per-type metadata table (file name, source-of-truth label, section-preservation rule) lives at the top of `src/ai/prompts/refine.js`. Adds 16 tests in `test/commands/refine.test.js`. Updates CHANGELOG `[Unreleased] ### Added`, CLAUDE.md (commands list, v1 status #7, new "Refine, don't clobber" design principle), README commands table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the long-standing "AI-assisted spec merge mode" open question (CLAUDE.md #4 historically). Re-running
new/tech/tasksagainst an existing spec would overwrite PM edits — both `--force` (overwrite) and cancel are blunt. `refine` is the alternative.Different shape from `clarify`:
What it does
`draftwise refine [] [--type=product|tech|tasks]` reads the chosen file plus its source-of-truth and prints a three-phase agent instruction:
(unverified)or remove any code reference the scanner doesn't surface.Hard rules in the prompt:
Type-aware behavior
--typeproduct(default)product-spec.mdexiststechtechnical-spec.mdexiststaskstasks.mdexistsSame auto-pick / multi-spec / unknown-slug ergonomics as `tech`.
What changed
Test plan